//related to picker3.ui
var page = sm("do_Page");
var app = sm("do_App");
var storage = sm("do_Storage");
var nf = sm("do_Notification");
var root = ui("$");
var homemakingUtil = require("url/homemaking");
var qqHttp = require("helper/http");

var aLayout_payType1 = ui("aLayout_payType1");
var aLayout_payType2 = ui("aLayout_payType2");
var label_payType1 = ui("label_payType1");
var label_payType2 = ui("label_payType2");
var param= {};

//遮罩显示
var animMaskShow = mm("do_Animator");
var propsMS = {bgColor:"00000077"};
animMaskShow.append(360,propsMS,"EaseOut");
//面板显示
var animPanelShow = mm("do_Animator");
var propsPS = {y:460};
animPanelShow.append(360,propsPS,"EaseOut");
//遮罩隐藏
var animMaskHide = mm("do_Animator");
var propsMH = {bgColor:"00000000"};
animMaskHide.append(360,propsMH,"EaseIn");
//面板隐藏
var animPanelHide = mm("do_Animator");
var propsPH = {y:960};
animPanelHide.append(360,propsPH,"EaseIn");

//picker
var labtit = ui("labtit");
var pickerbg = ui("pickerbg");//遮罩
var btnsure = ui("labButton");//确定按钮
var pickerbox = ui("do_ALayout_1");

page.on("showPayType",function(data){
	pickerbg.visible = true;
	pickerbg.animate(animMaskShow);
	pickerbox.animate(animPanelShow);
});

page.on("getPayType",function(data){
	if (data.payType == 1) { //货到付款
		param.payTypeStr = '货到付款';
		param.payType = 1;
		label_payType1.border="ff7e00FF,1,4";
		label_payType1.fontColor="ff7e00FF";
		label_payType2.border="C4C9D0FF,1,4";
		label_payType2.fontColor="949eaaFF";
	} else { //在线支付
		param.payTypeStr = '在线支付';
		param.payType = 2;
		label_payType2.border="ff7e00FF,1,4";
		label_payType2.fontColor="ff7e00FF";
		label_payType1.border="C4C9D0FF,1,4";
		label_payType1.fontColor="949eaaFF";
	}
});

//确定事件
btnsure.on("touch",function(){
	if (!param || !param.payTypeStr || !param.payType) {
		nf.toast("请选择一种支付方式");
		return;
	}
	pickerbox.animate(animPanelHide);
	pickerbg.animate(animMaskHide,function(){
		pickerbg.visible = false;
	});
	page.fire("refreshPayType",param);
});

//遮罩事件
pickerbg.on("touch","",300,function(){
	pickerbox.animate(animPanelHide);
	pickerbg.animate(animMaskHide,function(){
		pickerbg.visible = false;
	});
});

//防穿透
pickerbox.on("touch",function(){})

aLayout_payType2.on("touch", function(data) {
	param.payTypeStr = '在线支付';
	param.payType = 2;
	label_payType2.border="ff7e00FF,1,4";
	label_payType2.fontColor="ff7e00FF";
	label_payType1.border="C4C9D0FF,1,4";
	label_payType1.fontColor="949eaaFF";
});

aLayout_payType1.on("touch", function(data) {
	param.payTypeStr = '货到付款';
	param.payType = 1;
	label_payType1.border="ff7e00FF,1,4";
	label_payType1.fontColor="ff7e00FF";
	label_payType2.border="C4C9D0FF,1,4";
	label_payType2.fontColor="949eaaFF";
});
